#ifndef TD_FADING_MESSAGE_H_
#define TD_FADING_MESSAGE_H_

/************************************************************************/
/* STL                                                                  */
/************************************************************************/
#include <string>

/************************************************************************/
/* PROJECT                                                              */
/************************************************************************/

/************************************************************************/
/* Core                                                                 */
/************************************************************************/
#include "Core/Coord2D.h"

/************************************************************************/
/* GUI                                                                  */
/************************************************************************/
#include "GUI/TextMessages/BaseTextMessage.h"

/************************************************************************/
/* Resources                                                            */
/************************************************************************/
#include "Resources/SDLFont.h"
#include "Resources/ResourceManager.h"

namespace TD_GUI {

	class FadingMessage : public BaseTextMessage {
		/************************************************************************/
		/* Default definitions                                                  */
		/************************************************************************/
		static const int defaultHoldingTime;

		int m_alphaChannel;
		int m_timeBeforeFade;
		int m_ticks;
		bool m_fadedAnimation;

		bool m_fadingIn;

	public:

		/************************************************************************/
		/* ctors and dtors					                                    */
		/************************************************************************/
		//Default constructor
		explicit FadingMessage();

		//Copy constructor
		explicit FadingMessage(const FadingMessage &rhs);

		//Assignment constructor
		FadingMessage& operator=(const FadingMessage &rhs);

		//Destructor
		~FadingMessage();

		//Initialization constructor
		FadingMessage(const Coord2D &textPos, const string &initString, const string &fontSource, 
			unsigned int fontSize, const Color &fontColor, bool gFadingIn = false, int holdTime = defaultHoldingTime, renderType g_renderType = textBlended);


		/************************************************************************/
		/* Rendering                                                            */
		/************************************************************************/
		void render(SDL_Surface *const g_destSurface, unsigned int deltaTime);

		/************************************************************************/
		/* Access functions                                                     */
		/************************************************************************/

		bool isFinished() const {
			return(m_fadedAnimation);
		}

		void setFadeIn(bool enable) {
			m_fadingIn = enable;
		}

		void finishFading() {
			if(m_fadingIn) {
				m_alphaChannel = 255;
				m_fadedAnimation = true;
			} else {
				m_alphaChannel = 0;
				m_fadedAnimation = true;
			}
		}

		inline void resetFading() {
			m_fadedAnimation = false;
			if(m_fadingIn) {
				m_ticks = 0;
				m_alphaChannel = 0;
			} else {
				m_ticks = 0;
				m_alphaChannel = 255;
			}
		}
	};
}
#endif